package com.electronic.domain;

import com.cebpubservice.cashare.sdk.electronicsealsignatureandverifysignature.ElectronicSealSignatureAndVerifySignatureSingleton;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;



/**
 * @Author: IFCA
 * @Description: Cebs配置
 */
@Slf4j
@AllArgsConstructor
public class CebsConfiguration {

    public static void init(CebsSdkProperties cebsSdkProperties) {
        if (cebsSdkProperties.getCAShareToken()==null){
            log.info("=====未配置CAShareToken，使用原方法初始化");
           // 调用SDK初始化方法
            ElectronicSealSignatureAndVerifySignatureSingleton.init(
                    // 交易系统/交易工具编码
                    cebsSdkProperties.getTradingSystemCode(),
                    // CA互认共享组件地址
                    cebsSdkProperties.getServiceUrl(),
                    // 客户端id
                    cebsSdkProperties.getClientId(),
                    // 客户端密钥
                    cebsSdkProperties.getClientSecret(),
                    // 签名密钥
                    cebsSdkProperties.getAccessKeySecret());
            log.info("=====中招SDK初始化完成=====");
        }else {
            ElectronicSealSignatureAndVerifySignatureSingleton.init(
                    // 交易系统/交易工具编码
                    cebsSdkProperties.getTradingSystemCode(),
                    // CA互认共享组件地址
                    cebsSdkProperties.getServiceUrl(),
                    // 签名密钥
                    cebsSdkProperties.getCAShareToken(),
                    //签名密钥
                    cebsSdkProperties.getAccessKeySecret()
                    );
            log.info("=====已配置CAShareToken，使用加密方法初始化");
        }



    }
}
